home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / accessibility / nsAccessNode.h < prev    next >
C/C++ Source or Header  |  2006-05-08  |  6KB  |  156 lines

  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4.  *
  5.  * The contents of this file are subject to the Mozilla Public License Version
  6.  * 1.1 (the "License"); you may not use this file except in compliance with
  7.  * the License. You may obtain a copy of the License at
  8.  * http://www.mozilla.org/MPL/
  9.  *
  10.  * Software distributed under the License is distributed on an "AS IS" basis,
  11.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12.  * for the specific language governing rights and limitations under the
  13.  * License.
  14.  *
  15.  * The Original Code is mozilla.org code.
  16.  *
  17.  * The Initial Developer of the Original Code is
  18.  * Netscape Communications Corporation.
  19.  * Portions created by the Initial Developer are Copyright (C) 2003
  20.  * the Initial Developer. All Rights Reserved.
  21.  *
  22.  * Contributor(s):
  23.  *   Original Author: Aaron Leventhal (aaronl@netscape.com)
  24.  *
  25.  * Alternatively, the contents of this file may be used under the terms of
  26.  * either of the GNU General Public License Version 2 or later (the "GPL"),
  27.  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  28.  * in which case the provisions of the GPL or the LGPL are applicable instead
  29.  * of those above. If you wish to allow use of your version of this file only
  30.  * under the terms of either the GPL or the LGPL, and not to allow others to
  31.  * use your version of this file under the terms of the MPL, indicate your
  32.  * decision by deleting the provisions above and replace them with the notice
  33.  * and other provisions required by the GPL or the LGPL. If you do not delete
  34.  * the provisions above, a recipient may use your version of this file under
  35.  * the terms of any one of the MPL, the GPL or the LGPL.
  36.  *
  37.  * ***** END LICENSE BLOCK ***** */
  38.  
  39. /* For documentation of the accessibility architecture, 
  40.  * see http://lxr.mozilla.org/seamonkey/source/accessible/accessible-docs.html
  41.  */
  42.  
  43. #ifndef _nsAccessNode_H_
  44. #define _nsAccessNode_H_
  45.  
  46. #include "nsCOMPtr.h"
  47. #include "nsIAccessNode.h"
  48. #include "nsPIAccessNode.h"
  49. #include "nsIDocShellTreeItem.h"
  50. #include "nsIDOMNode.h"
  51. #include "nsIStringBundle.h"
  52. #include "nsWeakReference.h"
  53. #include "nsInterfaceHashtable.h"
  54.  
  55. class nsIPresShell;
  56. class nsPresContext;
  57. class nsIAccessibleDocument;
  58. class nsIFrame;
  59. class nsIDOMNodeList;
  60. class nsITimer;
  61.  
  62. enum { eChildCountUninitialized = 0xffff };
  63.  
  64. #define ACCESSIBLE_BUNDLE_URL "chrome://global-platform/locale/accessible.properties"
  65. #define PLATFORM_KEYS_BUNDLE_URL "chrome://global-platform/locale/platformKeys.properties"
  66.  
  67. /* hashkey wrapper using void* KeyType
  68.  *
  69.  * @see nsTHashtable::EntryType for specification
  70.  */
  71. class nsVoidHashKey : public PLDHashEntryHdr
  72. {
  73. public:
  74.   typedef const void* KeyType;
  75.   typedef const void* KeyTypePointer;
  76.   
  77.   nsVoidHashKey(KeyTypePointer aKey) : mValue(aKey) { }
  78.   nsVoidHashKey(const nsVoidHashKey& toCopy) : mValue(toCopy.mValue) { }
  79.   ~nsVoidHashKey() { }
  80.  
  81.   KeyType GetKey() const { return mValue; }
  82.   KeyTypePointer GetKeyPointer() const { return mValue; }
  83.   PRBool KeyEquals(KeyTypePointer aKey) const { return aKey == mValue; }
  84.  
  85.   static KeyTypePointer KeyToPointer(KeyType aKey) { return aKey; }
  86.   static PLDHashNumber HashKey(KeyTypePointer aKey) { return NS_PTR_TO_INT32(aKey) >> 2; }
  87.   enum { ALLOW_MEMMOVE = PR_TRUE };
  88.  
  89. private:
  90.   const void* mValue;
  91. };
  92.  
  93. class nsAccessNode: public nsIAccessNode, public nsPIAccessNode
  94. {
  95.   public: // construction, destruction
  96.     nsAccessNode(nsIDOMNode *, nsIWeakReference* aShell);
  97.     virtual ~nsAccessNode();
  98.  
  99.     NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
  100.     NS_IMETHOD_(nsrefcnt) AddRef(void);
  101.     NS_IMETHOD_(nsrefcnt) Release(void);
  102.     NS_DECL_NSIACCESSNODE
  103.     NS_DECL_NSPIACCESSNODE
  104.  
  105.     static void InitXPAccessibility();
  106.     static void ShutdownXPAccessibility();
  107.  
  108.     // Static methods for handling per-document cache
  109.     static void PutCacheEntry(nsInterfaceHashtable<nsVoidHashKey, nsIAccessNode>& aCache, 
  110.                               void* aUniqueID, nsIAccessNode *aAccessNode);
  111.     static void GetCacheEntry(nsInterfaceHashtable<nsVoidHashKey, nsIAccessNode>& aCache, void* aUniqueID, 
  112.                               nsIAccessNode **aAccessNode);
  113.     static void ClearCache(nsInterfaceHashtable<nsVoidHashKey, nsIAccessNode>& aCache);
  114.  
  115.     static PLDHashOperator PR_CALLBACK ClearCacheEntry(const void* aKey, nsCOMPtr<nsIAccessNode>& aAccessNode, void* aUserArg);
  116.  
  117.     // Static cache methods for global document cache
  118.     static already_AddRefed<nsIAccessibleDocument> GetDocAccessibleFor(nsIWeakReference *aPresShell);
  119.     static already_AddRefed<nsIAccessibleDocument> GetDocAccessibleFor(nsISupports *aContainer);
  120.     static already_AddRefed<nsIAccessibleDocument> GetDocAccessibleFor(nsIDOMNode *aNode);
  121.  
  122.     static already_AddRefed<nsIDocShellTreeItem> GetDocShellTreeItemFor(nsIDOMNode *aStartNode);
  123.     static already_AddRefed<nsIPresShell> GetPresShellFor(nsIDOMNode *aStartNode);
  124.     
  125.     static nsIDOMNode *gLastFocusedNode;
  126.  
  127. protected:
  128.     nsresult MakeAccessNode(nsIDOMNode *aNode, nsIAccessNode **aAccessNode);
  129.     already_AddRefed<nsIPresShell> GetPresShell();
  130.     nsPresContext* GetPresContext();
  131.     already_AddRefed<nsIAccessibleDocument> GetDocAccessible();
  132.  
  133.     nsCOMPtr<nsIDOMNode> mDOMNode;
  134.     nsCOMPtr<nsIWeakReference> mWeakShell;
  135.  
  136.     PRInt16 mRefCnt;
  137.     PRUint16 mAccChildCount;
  138.     NS_DECL_OWNINGTHREAD
  139.  
  140. #ifdef DEBUG
  141.     PRBool mIsInitialized;
  142. #endif
  143.  
  144.     // Static data, we do our own refcounting for our static data
  145.     static nsIStringBundle *gStringBundle;
  146.     static nsIStringBundle *gKeyStringBundle;
  147.     static nsITimer *gDoCommandTimer;
  148.     static PRBool gIsAccessibilityActive;
  149.     static PRBool gIsCacheDisabled;
  150.  
  151.     static nsInterfaceHashtable<nsVoidHashKey, nsIAccessNode> gGlobalDocAccessibleCache;
  152. };
  153.  
  154. #endif
  155.  
  156.